package com.yeskery.nut.extend.mcp.server;

import com.yeskery.nut.bean.ApplicationContext;
import com.yeskery.nut.extend.mcp.core.JsonResponse;
import com.yeskery.nut.util.JsonNullRemover;

/**
 * HTTP SSE MCP消息请求处理器
 * @author sprout
 * 2025-04-17 10:50
 */
public class HttpMcpMessageRequestHandler extends BaseHttpMcpMessageRequestHandler {

    /**
     * 构建HTTP SSE MCP消息请求处理器
     * @param applicationContext 应用上下文
     * @param mcpSessionManager MCP会话管理器
     * @param mcpServerCapability MCP服务能力
     */
    public HttpMcpMessageRequestHandler(ApplicationContext applicationContext, McpSessionManager mcpSessionManager, McpServerCapability mcpServerCapability) {
        super(applicationContext, mcpSessionManager, mcpServerCapability);
    }

    @Override
    protected boolean doResponse(McpRequestMetadata mcpRequestMetadata, JsonResponse jsonResponse) {
        mcpRequestMetadata.getResponse().writeJson(JsonNullRemover.removeNullFields(getResponsiveConvert().convertTo(jsonResponse)));
        return true;
    }

    @Override
    protected boolean supportServerSession() {
        return false;
    }
}
